<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 400px;
      height: 150px;
      background-color: red;
      position: relative;
      top: 0;
      left: 0;
      margin: 0 auto;
      text-align: center;
      line-height: 150px;
      font-size: 30px;
    }

    span {
      position: absolute;
      top: 0;
      right: 0;
      width: 20px;
      height: 20px;
      background-color: black;
      color: white;
      text-align: center;
      line-height: 20px;
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div class="box">
    广告
    <span>×</span>
  </div>
  <script>
    const span = document.querySelector('span')
    const box = document.querySelector('.box')
    span.addEventListener('click', function () {
      box.style.display = 'none'
    })
  </script>
</body>

</html>